Passed
Push — master ( fe7b3f...22651e )
by Andrey
08:30
created

$(document).ready   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
nc 4
nop 1
dl 0
loc 23
c 1
b 0
f 0
cc 5
rs 9.0333
1
$(document).ready(function () {
2
3
    $('.navbar .dropdown-item.dropdown').on('click', function (e) {
4
        var $el = $(this).children('.dropdown-toggle');
5
        if ($el.length > 0 && $(e.target).hasClass('dropdown-toggle')) {
6
            var $parent = $el.offsetParent(".dropdown-menu");
7
            $(this).parent("li").toggleClass('open');
8
9
            if (!$parent.parent().hasClass('navbar-nav')) {
10
                if ($parent.hasClass('show')) {
11
                    $parent.removeClass('show');
12
                    $el.next().removeClass('show');
13
                    $el.next().css({"top": -999, "left": -999});
14
                } else {
15
                    $parent.parent().find('.show').removeClass('show');
16
                    $parent.addClass('show');
17
                    $el.next().addClass('show');
18
                    $el.next().css({"top": $el[0].offsetTop, "left": $parent.outerWidth() - 4});
19
                }
20
                e.preventDefault();
21
                e.stopPropagation();
22
            }
23
            return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
24
        }
25
    });
26
27
    $('.navbar .dropdown').on('hidden.bs.dropdown', function () {
28
        $(this).find('li.dropdown').removeClass('show open');
29
        $(this).find('ul.dropdown-menu').removeClass('show open');
30
    });
31
32
});
33